﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sublimation
{
    public class SlotFlame : SlotWeapon
    {
        protected const int NB_PER_WAVE = 20;
        public SlotFlame(WorldProperties worldProperties, SlotKind kind, Tower ownerTower)
            : base(worldProperties, kind, ownerTower)
        {
            //Position = ownerTower.Position;


            RangedDamage = 10;
            RangedAttackDelay = 200;
            RangedFlightSpeed = 500;


        }

        protected override void LoadContent()
        {
            base.LoadContent();
            Sprite = Game.Content.Load<Texture2D>("Sprites/t_cannon");
        }

        protected override void RangedAttack(GameObject target, GameTime gameTime)
        {
            float slotRotation = orientation + ownerTower.Rotation;

            //get the minimum angle
            float min_angle = ((slotRotation - angle));


            //get the maximum angle
            float max_angle = ((slotRotation + angle)) ;


            Vector2 bulletVelocity;

            for (int i = 0; i < NB_PER_WAVE; i++)
            {
                float temp = i*(max_angle - min_angle) / NB_PER_WAVE;
                bulletVelocity = new Vector2((float)Math.Cos(temp + min_angle), (float)Math.Sin(temp + min_angle)); ;
                new Bullet(worldProperties, true, ownerTower.Position, bulletVelocity, RangedFlightSpeed, new Vector2(10, 10), Range, RangedDamage);
            }
        }
    }
}

